
<template>
  <el-container class="container">
    <el-header class="home-header">
      <el-row :gutter="20">
        <el-col :span="4"><img src="@/assets/images/logo.png" alt=""></el-col>
        <el-col :span="14"><h3>电商后台管理系统</h3></el-col>
        <el-col :span="6" class='logout-desc'><p>欢迎上海前端28期星曜会员 <a href="javascript:;" class="logout" @click.prevent='logout'>退出</a></p></el-col>
      </el-row>
    
    </el-header>
    <el-container  class="home-content">
      <el-aside width="200px" class="home-aside">
        <!-- router	是否使用 vue-router 的模式，启用该模式会在激活导航时以 index 作为 path 进行路由跳转 -->
        <el-menu
          :router="true"
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item index="/users">
              <i class="el-icon-menu"></i>
              <span slot="title">用户列表</span>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>权限管理</span>
            </template>
            <el-menu-item index="/roles">
              <i class="el-icon-menu"></i>
              <span slot="title">角色列表</span>
            </el-menu-item>
            <el-menu-item index="/rights">
              <i class="el-icon-menu"></i>
              <span slot="title">权限列表</span>
            </el-menu-item>
          </el-submenu>

        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  methods: {
    logout(){
      // 退出弹框事件
       this.$confirm('此操作将永久退出该页面, 是否继续?', '温馨提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // 退出成功则跳转到登录页
          this.$router.push('/login')
          // 删除token
          localStorage.removeItem('token')
          this.$message({
            type: 'success',
            message: '退出成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出'
          });          
        });
    },

  }
}
</script>

<style>
.container {
  height: 100%;
}
.home-header {
  background: #B3C1CD;
  line-height: 60px;
}
.home-header img {
  width: 180px;
}
.home-header h3 {
  text-align: center;
  font-size: 30px;
  color: #fff;
}
.home-header .logout-desc {
  min-width: 236px;
  font-weight: bold;
}
.home-header .logout {
  color: orange;
}
.home-aside {
  background: #545C64;
}
.home-content {
  height: 100%;
  background: #EAEEF1;
}
</style>
